#pragma once
#include "MobileTile.h"
#include "FixedTile.h"
#include "Tile.h"
#include <vector>
#include <map>
#include "../constantes.h"

//#include "GridIterator.h"

namespace Control{
	class Controller;
}
namespace Model{
	class Grid
	{
	private:
		vector<Tile*> tiles;
		map<int,MobileTile*> pushableTiles;
		Tile* firstTile;
		friend class GridIterator;
		friend class Control::Controller;
	public:
		MobileTile* getPushableTile(int tileId);
		MobileTile* pushTile(MobileTile* freeTile, int pushableTileId);
		Grid();
		void init();
		~Grid();
		void newPosOfIfPush(int row,int column, int *x,int *y);
		Grid* clone();

		class GridIterator
		{
		private:
			Grid* myGrid;
			Tile* ec;
		public:
			void init();
			void up();
			void down();
			void left();
			void right();
			Tile* getEc();
			void setEc(Tile* ec);
			bool hasUp();
			bool hasDown();
			bool hasLeft();
			bool hasRight();

			/*
			void endRow();
			void beginRow();
			void endColumn();
			void beginColumn();
			bool outOfBounds();
			*/
			GridIterator(Grid* g);
			~GridIterator(void);
		};

		GridIterator* getIterator();
	};
}
